#ifndef K_SOCK_CONTEXT_H
#define K_SOCK_CONTEXT_H
#pragma once

#include "KDef.h"
#include "KTcpSocket.h"
#include "KUdpSocket.h"

class KSocketContext : public KDef::SocketContext, public KSocket {
public:
    virtual ~KSocketContext();
public:
    virtual Context *getContext()   { return this; }
    virtual KSocket *getSocket()    { return this; }
};

class KTcpSocketContext : public KDef::SocketContext, public KTcpSocket {
public:
    virtual ~KTcpSocketContext();
public:
    virtual Context *getContext()   { return this; }
    virtual KSocket *getSocket()    { return this; }
};

class KUdpSocketContext : public KDef::SocketContext, public KUdpSocket {
public:
    virtual ~KUdpSocketContext();
public:
    virtual Context *getContext()   { return this; }
    virtual KSocket *getSocket()    { return this; }
};

inline KSocketContext::~KSocketContext()
{
    checkSetLinger(true);
    clearRequests();
}

inline KTcpSocketContext::~KTcpSocketContext()
{
    checkSetLinger(true);
    clearRequests();
}

inline KUdpSocketContext::~KUdpSocketContext()
{
    clearRequests();
}

#endif // K_SOCK_CONTEXT_H